/**
 * Create by mzq
 * Description: 用于导出pdf修改路径方法
 * Date: 2025/2/8 10:39
 * Update: 2025/2/8 10:39
 */

/**
 * 获取绝对路径pdf版本
 * @param relativePath
 * @returns {Promise<unknown>}
 */
export function getAbsolutePath(relativePath) {
    return new Promise((resolve, reject) => {
        // 使用 plus.io 解析路径
        plus.io.resolveLocalFileSystemURL(relativePath, function(entry) {
            // 获取绝对路径
            const absolutePath = entry.toLocalURL();
            // 去掉 file:// 前缀
            const cleanPath = absolutePath.replace('file://', '');
            resolve(cleanPath);
        }, function(error) {
            reject(error);
        });
    });
}

/**
 * 提示框
 * @param title
 * @param param
 */
export const toast = (title = '', param = {}) => {
    if (!title) return
    uni.showToast({
        title,
        duration: param.duration || 1500,
        mask: param.mask || false,
        icon: param.icon || 'none',
    })
}